LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads State State

Contents

record State <S, A> (Func<S, (A Value, S State)> runState) Source #

State monad transformer, which adds a modifiable state to a given monad.

Parameters

type S

State type

type M

Given monad trait

type A

Bound value type

param runState

Transducer that represents the transformer operation

Properties

property State<S, S> Get Source #

Extracts the state value and returns it as the bound value

Parameters

returns

State

Methods

method State<S, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

State

method State<S, Unit> Modify (Func<S, S> f) Source #

Extracts the state value, maps it, and then puts it back into the monadic state.

Parameters

param f

State mapping function

returns

State

method State<S, Unit> Put (S value) Source #

Writes the value into the monadic state

Parameters

returns

State

method State<S, A> Gets (Func<S, A> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

State

method State<S, A> GetsM (Func<S, State<S, A>> f) Source #

Extracts the state value and maps it to the bound value

Parameters

param f

State mapping function

returns

State

method State<S, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

State

method State<S, A> Lift (Func<A> f) Source #

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

State

method State<S, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

State

method State<S, B> Bind <B> (Func<A, K<State<S>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, B> Bind <B> (Func<A, State<S, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, B> Bind <B> (Func<A, Gets<S, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, Unit> Bind (Func<A, Put<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, Unit> Bind (Func<A, Modify<S>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

State

method State<S, C> SelectMany <B, C> (Func<A, K<State<S>, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method State<S, C> SelectMany <B, C> (Func<A, State<S, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method State<S, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method State<S, C> SelectMany <C> (Func<A, Put<S>> bind, Func<A, Unit, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method State<S, C> SelectMany <B, C> (Func<A, Gets<S, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method State<S, C> SelectMany <C> (Func<A, Modify<S>> bind, Func<A, Unit, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

State

method (A Value, S State) Run (S state) Source #

Run the state monad

Parameters

param state

Initial state

returns

Bound monad

class StateExtensions Source #

State monad extensions

Methods

method State<S, A> As <S, A> (this K<State<S>, A> ma) Source #

method State<S, A> Flatten <S, A> (this State<S, State<S, A>> mma) Source #

Monadic join

method State<S, A> Flatten <S, A> (this State<S, K<State<S>, A>> mma) Source #

Monadic join

class State <S> Source #

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method State<S, A> Pure <A> (A value) Source #

class State Source #

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method State<S, B> bind <S, A, B> (State<S, A> ma, Func<A, State<S, B>> f) Source #

method State<S, B> map <S, A, B> (Func<A, B> f, State<S, A> ma) Source #

method State<S, A> Pure <S, A> (A value) Source #

method State<S, B> apply <S, A, B> (State<S, Func<A, B>> mf, State<S, A> ma) Source #

method State<S, B> action <S, A, B> (State<S, A> ma, State<S, B> mb) Source #

method State<S, S> get <S> () Source #

method State<S, A> gets <S, A> (Func<S, A> f) Source #

method State<S, A> getsM <S, A> (Func<S, State<S, A>> f) Source #

method State<S, Unit> put <S> (S state) Source #

method State<S, Unit> modify <S> (Func<S, S> f) Source #

class State <S> Source #

Traits implementation for State

Parameters

type S

State environment type